﻿using System;
//using System.ComponentModel;
using System.Drawing;
using System.Drawing.Text;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using Notepad_X.Classes;
namespace Notepad_X
{
    public partial class About : Form
    {
        Main main;

        //Effect variables
        int currentGradientShift = 10;
        int gradiantStep = 5;
        Color c = new Color();

        public About()
        {
            main = Static.MainInstance;
            InitializeComponent();
        }

        private void About_Load(object sender, EventArgs e)
        {
          c = Color.FromArgb(76, 197, 82);
          if (Main.app_language.language.ToLower() != "english")
          {
              about_translator.Visible = true;
              about_translation.Visible = true;
              about_translator.Text = Main.app_language.Author;
          }
          else
          {
              about_translation.Visible = false;
              about_translator.Visible = false;
          }
          this.Text = Main.app_language[Strings.About];
          about_translation.Text = Main.app_language[Strings.Author];
          about_close.Text = Main.app_language[Strings.Close];
          about_dev.Text = Main.app_language[Strings.Developers];

          if (main.IconsCollection.Images.ContainsKey("about"))
          {
              Icon = System.Drawing.Icon.FromHandle(new System.Drawing.Bitmap(main.IconsCollection.Images["about"]).GetHicon());
          }else{
              this.ShowIcon = false;
          }

          about_version.Text = Main.app_language[Strings.Version] + " " + Main.VersionName;     
        }

        private void effect_Tick(object sender, EventArgs e)
        {
            Random g = new Random();
            effect.Interval =(int)(10 * (0.5+g.NextDouble()));
            Graphics grfx  = CreateGraphics();
            Font font = new Font("Microsoft Sans Serif", 35, FontStyle.Bold, GraphicsUnit.Point);
            String strText="Notepad X";
            SizeF sizfText = new SizeF(grfx.MeasureString(strText,font));
            PointF ptfTextStart = new PointF(5,5);
            PointF ptfGradientStart = new PointF(0,0);
            PointF ptfGradientEnd = new PointF((float)(currentGradientShift),100);
            LinearGradientBrush grBrush = new LinearGradientBrush(ptfGradientStart,ptfGradientEnd,c ,Color.WhiteSmoke);
            grfx.DrawString(strText, font, grBrush, ptfTextStart);

            grfx.Dispose();

            currentGradientShift += gradiantStep;
            if(currentGradientShift == 200) 
            {
                gradiantStep = -5;
            }else if(currentGradientShift == -50){
                gradiantStep = 5;
            }
        }

        private void close_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void about_website_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                System.Diagnostics.Process.Start("http://notepad-x.sourceforge.net");
            }catch (Exception)
            {}

        }

        private void about_nohponex_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                System.Diagnostics.Process.Start("http://notepad-x.sourceforge.net/?author=1");
            }
            catch (Exception)
            {}

        }

        private void about_licence_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                System.Diagnostics.Process.Start("http://www.gnu.org/licenses/gpl.html");
            }
            catch (Exception)
            {}
        }

        private void about_donate_Click(object sender, EventArgs e)
        {
            try
            {
                System.Diagnostics.Process.Start("http://sourceforge.net/project/project_donations.php?group_id=202614");
            }
            catch (Exception)
            {}
        }
    }
}
